<div
    bsModal
    (onShown)="onShown()"
    #createOrEditModal="bs-modal"
    class="modal fade"
    tabindex="-1"
    role="dialog"
    aria-labelledby="createOrEditModal"
    aria-hidden="true"
    [config]="{ backdrop: 'static' }"
>
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <form *ngIf="active" #editForm="ngForm" novalidate (ngSubmit)="save()" autocomplete="off">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span *ngIf="pici.id"> 编辑: {{ pici.name }}</span>
                        <span *ngIf="!pici.id"> 新增 </span>
                    </h4>
                    <button type="button" class="close" (click)="close()" [attr.aria-label]="l('Close')">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label>名称 *</label>
                        <input
                            id="PiciNameInput"
                            #piciNameInput="ngModel"
                            class="form-control"
                            type="text"
                            name="Name"
                            [(ngModel)]="pici.name"
                            required
                        />
                        <validation-messages [formCtrl]="piciNameInput"></validation-messages>
                    </div>
                    <div class="form-group">
                        <label>数量 *</label>
                        <input
                            #piciQuantityInput="ngModel"
                            class="form-control"
                            type="number"
                            name="Quantity"
                            [(ngModel)]="pici.quantity"
                            required
                            min="1"
                        />
                        <validation-messages [formCtrl]="piciQuantityInput"></validation-messages>
                    </div>
                    <div class="form-group">
                        <label>型号 </label>
                        <input
                            #piciModelInput="ngModel"
                            class="form-control"
                            type="text"
                            name="Model"
                            [(ngModel)]="pici.model"
                        />
                        <validation-messages [formCtrl]="piciModelInput"></validation-messages>
                    </div>

                    <div class="form-group">
                        <label>任务号前缀 *</label>
                        <input
                            #piciTaskPrefixesInput="ngModel"
                            class="form-control"
                            type="text"
                            name="TaskPrefixes"
                            [(ngModel)]="pici.taskPrefixes"
                        />
                        <validation-messages [formCtrl]="piciTaskPrefixesInput"></validation-messages>
                    </div>
                </div>
                <div class="modal-footer">
                    <button [disabled]="saving" type="button" class="btn btn-secondary" (click)="close()">
                        {{ l("Cancel") }}
                    </button>
                    <button
                        type="submit"
                        class="btn btn-primary"
                        [disabled]="!editForm.form.valid"
                        [buttonBusy]="saving"
                        [busyText]="l('SavingWithThreeDot')"
                    >
                        <i class="fa fa-save"></i> <span>{{ l("Save") }}</span>
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
